package cn.com.api.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.api.entity.ApiU_resource;
import cn.com.api.mapper.base.U_resourceMapperBase;

//DAO
public interface ApiU_resourceMapper extends U_resourceMapperBase {

	// 新增对象后返回记录ID
	public int U_resourceInsertion(ApiU_resource u_resource);

	// 根据类型获得资源集合
	public List<ApiU_resource> findU_resourcesByCondition(Map<String, Object> param);

	// 添加
	@Insert("INSERT INTO U_RESOURCE (RES_NAME, RES_URL, CREATE_TIME, STATUS, RES_IMAGE, TYPE) "
			+ "VALUES (#{res_name,jdbcType=VARCHAR}, #{res_url,jdbcType=VARCHAR}, #{create_time,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{res_image,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR})")
	@Options(useGeneratedKeys = true, keyProperty = "resource_id")
	public int insertU_resource_info(ApiU_resource u_resource);

	@Update("UPDATE U_RESOURCE SET RES_NAME = #{res_name}, RES_URL = #{res_url}, CREATE_TIME = #{create_time}, TYPE = #{type},STATUS = #{status},RES_IMAGE = #{res_image} WHERE RESOURCE_ID = #{resource_id}")
	public int updateU_resource_info(ApiU_resource u_resource);

	@Select("SELECT * from U_RESOURCE where type = #{type,jdbcType=VARCHAR}")
	public List<ApiU_resource> findU_resources_type(Map<String, Object> param);

}
